
Ext.define('js.project.ProjectMergerAddPage', {
    extend: 'Ext.form.Panel',
    requires: ['js.Util', 'js.ctrl.Common'],
    controller: 'Common',
    url:'engineeringRoutes',
/*    scrollable: true,*/
    config: {
        bodyPadding: '0 20 0 20',
        layout: {
            type: 'vbox',
            align: 'stretch'
        }
    },
    userGroupForm: function () {
        return Ext.create('js.system.EngineeringAddPage');
    },
    userGroupFormA: function () {
        return Ext.create('js.system.ConstructionAddPage');
    },
    userGroupFormB: function () {
        return Ext.create('js.system.RegionAddPage');
    },
    hidenField: {
        region_id: undefined
    },
    fieldDefaults: {
        labelWidth:100,
        flex:1,
        allowBlank: false
    },
    initComponent: function () {

        Ext.QuickTips.init();
        Ext.form.Field.prototype.msgTarget = 'under';
        let eng_id = {
            xtype: 'textfield',
            name: 'eng_id',
            id: 'eng_id',
            allowBlank: false,
            hidden:true,
            msgTarget : 'qtip',
            height:36,
            margin:'20 0 10 0',
            labelSeparator: '',
            fieldLabel: '工程id:'
        };

        let project_name = {
            xtype: 'textfield',
            name: 'eng_name',
            id: 'eng_name',
            allowBlank: false,
            msgTarget : 'qtip',
            height:36,
            margin:'10 0 10 0',
            labelSeparator: '',
            width: '100',
            fieldLabel: '工程名称:'
        };
        let project_num = {
            xtype: 'textfield',
            name: 'eng_no',
            id: 'eng_no',
            allowBlank: false,
            width: '200',
            msgTarget : 'qtip',
            height:36,
            margin:'10 0 10 0',
            labelSeparator: '',
            fieldLabel: '工程编号:'
        };
        let project_start_data = {
            xtype: 'datefield',
            editable:false,
            name: 'eng_startDate',
            id: 'eng_startDate',
            allowBlank: false,
            msgTarget : 'qtip',
            height:36,
            margin:'10 0 10 0',
            labelSeparator: '',
            width: '200',
            fieldLabel: '开工日期:'
        };
        let panelA={
            xtype:'panel',
            margin:'10 0 1 0',
            layout: {
                type: 'hbox',
                align: 'stretch'
            },
            items:[{
                xtype: 'combobox',
                name: 'eng_structure_type',
                id: 'eng_structure_type',
                fieldLabel: '结构类型',
                margin:'1 0 0 0',
                allowBlank: false,
                triggerAction: 'all',
                msgTarget : 'qtip',
                editable : false,
                emptyText: '',
                width: '200',
                displayField: 'dataType',
                valueField: 'value',
                store:  Ext.create('js.store.wide.projectStructureType',{
                    proxy: {
                        extraParams: {
                            type: 1,
                        },
                    }
                }),
                listeners:{
                    "expand":function(combo, store,index){
                        Ext.getCmp("eng_structure_type").getStore().load();
                    }
                }
            },{
                xtype:'button',
                text:'+',
                margin:'1 0 0 0',
                scope: this,
                handler: this.RoleMergerAdd,
            }]
        };
        let panelB={
            xtype:'panel',
            margin:'10 0 1 0',
            layout: {
                type: 'hbox',
                align: 'stretch'
            },
            items:[{
                xtype: 'combobox',
                name: 'eng_building_use',
                id: 'eng_building_use',
                fieldLabel: '建筑用途',
                msgTarget : 'qtip',
                margin:'1 0 0 0',
                allowBlank: false,
                triggerAction: 'all',
                editable : false,
                emptyText: '',
                width: '200',
                displayField: 'dataType',
                valueField: 'value',
                store:  Ext.create('js.store.wide.projectConstructionApplications',{
                    proxy: {
                        extraParams: {
                            type: 1,
                        },
                    }
                }),
                listeners:{
                    "expand":function(combo, store,index){
                        Ext.getCmp("eng_building_use").getStore().load();
                    }
                }
            },{
                xtype:'button',
                text:'+',
                margin:'1 0 0 0',
                scope: this,
                handler: this.RoleMergerAddA,
            }]
        };
        let panelC={
            xtype:'panel',
            margin:'10 0 1 0',
            layout: {
                type: 'hbox',
                align: 'stretch'
            },
            items:[{
                xtype: 'combobox',
                name: 'eng_region_name',
                id: 'eng_region_name',
                fieldLabel: '工程地点区域',
                msgTarget : 'qtip',
                margin:'1 0 0 0',
                allowBlank: false,
                triggerAction: 'all',
                editable : false,
                emptyText: '',
                width: '200',
                displayField: 'dataType',
                valueField: 'value',
                store:  Ext.create('js.store.wide.projectRegin',{
                    proxy: {
                        extraParams: {
                            type: 1,
                        },
                    }
                }),
                listeners:{
                    "expand":function(combo, store,index){
                        Ext.getCmp("eng_region_name").getStore().load();
                    }
                }
            },{
                xtype:'button',
                text:'+',
                margin:'1 0 0 0',
                scope: this,
                handler: this.cxqyAdd,
            }]
        };
        let project_state = {
            xtype: 'combobox',
            name: 'eng_status',
            id: 'eng_status',
            fieldLabel: '工程状态',
            msgTarget : 'qtip',
            height:36,
            margin:'10 0 10 0',
            allowBlank: false,
            triggerAction: 'all',
            editable : false,
            emptyText: '',
            width: '200',
            displayField: 'dataType',
            valueField: 'value',
            store:  Ext.create('js.store.wide.projectState'),
        };

        this.items = [eng_id,project_name,project_start_data,panelA,panelB,panelC,project_state];

        this.callParent(arguments);
    },
    RoleMergerAdd:function(){
        let win = util.window(this.userGroupForm(), {title:'添加' ,width:'40%',height:'30%'});
        win.show();
    },
    RoleMergerAddA:function(){
        let win = util.window(this.userGroupFormA(), {title:'添加' ,width:'40%',height:'30%'});
        win.show();
    },
    cxqyAdd:function(){
        let win = util.window(this.userGroupFormB(), {title:'添加' ,width:'40%',height:'35%',bodyStyle: {backgroundColor: '#253746'}});
        win.show();
    },
});